﻿using System;
using System.Globalization;
using System.Windows.Forms;

namespace toNyxIncinerate
{
    public partial class CrSettingsForm : Form
    {
        public CrSettingsForm()
        {
            InitializeComponent();
        }

        #region Load/Close

        private void CrSettingsFormLoad(object sender, EventArgs e)
        {
            #region Spells

            cb_UseFireStorm.Checked = AbilitySettings.Instance.UseFireStorm;
            cb_UseProjectileWeakness.Checked = AbilitySettings.Instance.UseProjectileWeakness;
            txt_NumberOfTargetsMin.Text = AbilitySettings.Instance.ProjectileWeaknessMinimumEnemies.ToString(CultureInfo.InvariantCulture);
            cb_UseArcticArmour.Checked = AbilitySettings.Instance.UseArcticArmour;
            txt_CombatRange.Text = AbilitySettings.Instance.CombatRange.ToString(CultureInfo.InvariantCulture);
            txt_TPS.Text = AbilitySettings.Instance.TicksPerSeconds.ToString(CultureInfo.InvariantCulture);
            cb_TakeCorruptedAreas.Checked = Loki.Bot.CharacterSettings.Instance.TakeCorruptedAreas;

            #endregion
        }

        private void CrSettingsFormClosing(object sender, EventArgs e)
        {
            AbilitySettings.Instance.UseFireStorm = cb_UseFireStorm.Checked;
            AbilitySettings.Instance.UseProjectileWeakness = cb_UseProjectileWeakness.Checked;
            AbilitySettings.Instance.ProjectileWeaknessMinimumEnemies = Convert.ToInt32(txt_NumberOfTargetsMin.Text);
            AbilitySettings.Instance.UseArcticArmour = cb_UseArcticArmour.Checked;
            AbilitySettings.Instance.CombatRange = Convert.ToSingle(txt_CombatRange.Text);
            AbilitySettings.Instance.TicksPerSeconds = Convert.ToInt32(txt_TPS.Text);
            Loki.Bot.CharacterSettings.Instance.TakeCorruptedAreas = cb_TakeCorruptedAreas.Checked;

            // Save Data
            AbilitySettings.Instance.Save();
        }

        #endregion

        #region CheckBoxes

        private void CbUseFireStormCheckedChanged(object sender, EventArgs e)
        {
            AbilitySettings.Instance.UseFireStorm = cb_UseFireStorm.Checked;
        }

        private void CbUseProjectileWeaknessCheckedChanged(object sender, EventArgs e)
        {
            AbilitySettings.Instance.UseProjectileWeakness = cb_UseProjectileWeakness.Checked;
        }

        private void CbUseArcticArmourCheckedChanged(object sender, EventArgs e)
        {
            AbilitySettings.Instance.UseArcticArmour = cb_UseArcticArmour.Checked;
        }

        private void CbTakeCorruptedAreasCheckedChanged(object sender, EventArgs e)
        {
            Loki.Bot.CharacterSettings.Instance.TakeCorruptedAreas = cb_TakeCorruptedAreas.Checked;
        }

        #endregion

    }
}
